<?php
require_once("database.php");
class xl_work extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from work limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from work";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($uid)
	{
		
		$sql = "select * from work where uid = '$uid'";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function xoa($uid, $epid)
	{
		
		$sql = "delete from work where uid = '$uid', epid = '$epid'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($lcid, $pid, $description, $start_date, $end_date)
	{
		$description = addslashes($description);
		$start_date = addslashes($start_date);
		$end_date = addslashes($end_date);

		$sql = "INSERT INTO work(lcid,pid,description,start_date,end_date) VALUES ('$lcid','$pid','$description','$start_date','$end_date')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($uid, $epid, $lcid, $pid, $description, $start_date, $end_date)
	{
		$description = addslashes($description);
		$start_date = addslashes($start_date);
		$end_date = addslashes($end_date);

		$sql ="UPDATE work SET lcid= '$lcid', pid= '$pid', description= '$description', start_date= '$start_date', end_date= '$end_date' WHERE uid = '$uid', epid = '$epid'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from work where	$description like %tu_khoa% or 	$start_date like %tu_khoa% or 	$end_date like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>